<template>
     <AgGridVuesCopys :rowHeight="33" :headerHeight="33" :suppressCopyRowsToClipboard="true" rowSelection="multiple" @grid-ready="gridReady" 
        style="height:90%" class='ag-theme-alpine'
        :defaultColDef="defaultColDef" :rowData="table.dataList" 
        :columnDefs="cfsValue" :localeText="localeTextData"/>
    <paginationCopys :total="total" show-total show-jumper 
        show-page-size @change="changePage"    
        @page-size-change="changeSize" 
        style="justify-content: center;margin: 10px 0px 10px 0px;"  
        :page-size="pagination.pageSize" :current="pagination.page" />
</template>
<script lang="ts">
import { reactive, ref,onMounted } from 'vue'
import { useTable, useRowKey, useTableColumn, usePagination, useRowSelection } from '@/hooks/table'

import { localeText } from '@/api/aggridZw'
import emitter from "@/hooks/useEventBus";
import { Message } from '@arco-design/web-vue';
import { assTable } from '@/utils/assemblyLevelTable';
import { post } from '@/api/http'
export default {
    name:'widthPhyInfo',
    props:{
        searchData:{
           type:Object,
           default:() => {}
        }
     },
    setup(props){
        let searchData = {};
        onMounted(() => {
            // 第一个页面需要在刚进入就调用一次  切换tap时也需要调用
            doRefresh();
            emitter.on("refresh-widthPhyInfo", (val:any) => {
                console.log(props.searchData)
                console.log(val)
                doRefresh();
            });
        });
        const doRefresh = () => { 
            post({
                url:'pdm/VerifyManage/getTreatVerifyManage',
                data:{
                    page:pagination.page,
                    size:pagination.pageSize
                }
            }).then(({data})=>{
                   
            })
         };
        const gridOption = ref();
        const table = useTable();
        const gridReady = (params:any) => {
          gridOption.value = params.api;
          //调整表格自适应大小
        //   gridOption.value.sizeColumnsToFit(); 
        }
        const defaultColDef = {
            sortable: true,
            resizable: true,
            filter: true,
            width: 150
        };
        let cfsValue = [
            // {
            //     headerName: "序号",
            //     field: "serialNo",
            // },
            {
                headerName: "计划日期",
                field: "createOrderDate",
            },
            {
                headerName: "流转卡号",
                field: "flowCardCode",
            },
            {
                headerName: "缸型",
                field: "cylinderType",
            },
            {
                headerName: "测试耗时",
                field: "verifyTimeConsum",
            },
            {
                headerName: "客户名称",
                field: "customName",
            },
            {
                headerName: "计划单号",
                field: "planOrderCode",
            },
            {
                headerName: "计划交货日期",
                field: "lastDeliveryDate",
            },
            {
                headerName: "色号",
                field: "colorCode",
            },
            {
                headerName: "色称",
                field: "colorName",
            },
            {
                headerName: "布号",
                field: "clothCode",
            },
            {
                headerName: "品名",
                field: "brandName",
            },
            {
                headerName: "等待工序",
                field: "process",
            },
            {
                headerName: "匹数",
                field: "houseNum",
            },
            {
                headerName: "计划重量",
                field: "flowCardWeight",
            },
            {
                headerName: "出库重量",
                field: "outStockWeight",
            },
            {
                headerName: "回修原因",
                field: "repairReason",
            },
            {
                headerName: "出库日期",
                field: "stockOutDate",
            },
            {
                headerName: "终止说明",
                field: "stopExplain",
            },
            {
                headerName: "上一道结束工序",
                field: "frontProcess",
            },
            {
                headerName: "工序完成情况",
                field: "completeProcess",
            },
            {
                headerName: "成品入库",
                field: "productstockInState",
            },
            {
                headerName: "成品出库",
                field: "productstockOutState",
            },
        ]; 
        let a = [{
            showRowGroup: 'hide_def',
            "headerName": "",
            "checkboxSelection": true,
            "headerCheckboxSelection": true,
            "pinned": "left",
            "width": 50,
            resizable: false,
            filter: false,
            sortable: false,
            minWidth: 50,
            maxWidth: 50,
            lockPosition: "left",
        }]
        cfsValue = a.concat(cfsValue);
        const pagination = usePagination(doRefresh);
        const total = ref(10);
        const changePage = (val:any) => {
            pagination.page = val
            doRefresh();
        }
        const changeSize = (val:any) => {
            pagination.pageSize = val
            doRefresh();
        }
        emitter.on('export-widthPhyWordProce',() => { 
            let selectList = gridOption.value.getSelectedRows();
            console.log(selectList);
            if (selectList.length === 0) {
                Message.error('请勾选需要导出的数据')
                return
            } else {
                //导出数据
                let nowRow = table.dataList.filter(function (o) {
                    return (gridOption.value.getSelectedRows().map((o: any) => { return o.id })).indexOf(o["id"]) !== -1;
                })
                assTable(cfsValue,nowRow,'待物测信息明细');
            }
        });
        const localeTextData :any = ref(localeText);
        return {
            changePage,
            changeSize,
            localeTextData,
            defaultColDef,
            gridReady,
            cfsValue,
            total,  
            pagination,
            table
        }
    },
    components:{  }
}
</script>
<style lang="less" scoped>
    
</style>